package com.zuikaku.nettychat.web.controller;

import com.zuikaku.nettychat.netty.framework.NettyServer;
import com.zuikaku.nettychat.pojo.Chat;
import com.zuikaku.nettychat.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/system")
public class SystemController {


    @Autowired
    private NettyServer nettyServer;

    @Autowired
    private ChatService chatService;

    @GetMapping("/test/{arg}")
    @ResponseBody
    public String test(@PathVariable("arg")String arg){
        return "输入的字符串为:"+arg;
    }


    @GetMapping("/testMyBatis")
    @ResponseBody
    public String testMyBatis(){
        List<Chat> chatList= chatService.selectAll();
        return chatList.toString();
    }

    @GetMapping("/startServer")
    public void startServer(){
        nettyServer.startServer();
    }

}
